Network address translation (NAT) has been widely applied in Internet. The NAT technology is used to isolate an internal network from an external network (usually referring to Internet), so as to provide security protection for the internal network and also solve the problem that the Internet Protocol version 4 (IPv4) has insufficient addresses. For the NAT, a host in an NAT internal network is called an internal host and a host in an NAT external network is called an external host.
A peer to peer (P2P) technology makes full use of a capability of each node in a network, so that the nodes provide services for each other. The NAT allows a packet sent by an external host that has communicated with an internal host to enter the internal network, but a packet sent by an external host that has not ever communicated with an internal host may be discarded. In the P2P, each P2P node (peer) may serve as a server, and the other peers initiate requests for collecting resources to an internal host acting as a peer. The NAT may discard information sent by peers of the external network. In order to solve the problem, in a P2P containing NAT, an internal host may have three types of addresses as follows. The first is host candidate address, which is an interface address of an internal host. The second is server reflexive candidate address, which is an address assigned to the internal host by the NAT. The third is relay candidate address, which is an address assigned, to the internal host by a traversal using relays around NAT (TURN) server. After acquiring the three types of addresses, the external host may communicate with the internal host through the P2P technology. The NAT traversal refers that the communication is established between an internal host and an external host of an NAT. The NAT traversal resource refers to an entity providing services associated with the NAT traversal. The P2P peer forwards messages according to a certain routing policy. A routing process refers that a message is routed and forwarded on an overlay network according to a key value. A peer that forwards the message is called a middle peer. A destination of the message is called a destination peer.
In a related art, an NAT traversal resource is acquired through a universal service discovery mechanism. The P2P utilizes a Hash algorithm to calculate a key value of an NAT traversal resource and stores a peer that can provide the NAT traversal resource under the key value. When a first peer needs to search for the NAT traversal resource, the first peer sends a message for searching for the NAT traversal resource to the P2P. Then, according to the key value of the NAT traversal resource, the peer in charge of the key value is obtained. Then, the peer in charge of the key value sends the NAT service resource under the key value to the first peer, so that the first peer acquires the NAT traversal resource.
In the process of researching and implementing the related art, the inventor finds out the following problems in the related art. The number of peers in the P2P is rather large. Most of the peers are internal hosts of the NAT. In order to realize the P2P communication with other peers, the internal hosts send messages for searching for NAT traversal resources. As all these messages are sent to the peer in charge of the key values of the NAT traversal resources, the peer carries an excessively large work load, which may cause a searching failure.